import Vue from 'vue'
import Router from 'vue-router'
import bag from '../package'
Vue.use(Router)
// 生产/测试环境，使用路由懒加载
const view = process.env.NODE_ENV === 'development'
  ? file => require(`@/views/${file}.vue`).default
  : file => () => import(`@/views/${file}.vue`).then(m => m.default)
export const defaultTitle = bag.name
export const router = new Router({
  // mode: 'history',
  base: require('../package.json').name,
  routes: [
    {
      path: '/',
      name: 'index',
      component: view('index/Index'),
      children: [
        {
          path: '/',
          name: 'home',
          meta: {
            keepAlive: true
          },
          component: view('home/Index'),
        },
        {
          path: '/message',
          name: 'message',
          component: view('message/Index'),
        },
        {
          path: '/my',
          name: 'my',
          component: view('my/Index'),
        }
      ]
    }
  ]
})
